package com.sourcethought.xawz.view;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;

import com.sourcethought.xawz.R;

public class AdView extends RelativeLayout {
	private LayoutInflater layoutInflater;
	
	public AdView(Context context) {
		super(context);
		initComonent();
	}

	public AdView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initComonent();
	}

	public AdView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initComonent();
	}
	
	protected void initComonent(){
		layoutInflater = LayoutInflater.from(getContext());
		layoutInflater.inflate(R.layout.ad, this);
		
		setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				adViewOnClick(v);
			}
		});
	}
	
	public void adViewOnClick(View v){
		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.untuan.cn/"));
		getContext().startActivity(intent);
	}

}
